

package com.hazelcast.test.bounce;

import com.hazelcast.config.Config;

import java.util.function.Supplier;

/**
 * Configuration for a member bounce test.
 */
public class BounceTestConfiguration {

    private final int clusterSize;
    private final DriverType driverType;
    private final Supplier<Config> memberConfigSupplier;
    private final int driverCount;
    private final DriverFactory driverFactory;
    private final boolean useTerminate;
    private final boolean avoidOverlappingTerminations;
    private final int bouncingIntervalSeconds;
    private final long maximumStaleSeconds;

    BounceTestConfiguration(int clusterSize, DriverType driverType, Supplier<Config> memberConfigSupplier, int driverCount, DriverFactory driverFactory, boolean useTerminate, boolean avoidOverlappingTerminations, int bouncingIntervalSeconds, long maximumStaleSeconds) {
        this.clusterSize = clusterSize;
        this.driverType = driverType;
        this.memberConfigSupplier = memberConfigSupplier;
        this.driverCount = driverCount;
        this.driverFactory = driverFactory;
        this.useTerminate = useTerminate;
        this.avoidOverlappingTerminations = avoidOverlappingTerminations;
        this.bouncingIntervalSeconds = bouncingIntervalSeconds;
        this.maximumStaleSeconds = maximumStaleSeconds;
    }

    public int getClusterSize() {
        return clusterSize;
    }

    public DriverType getDriverType() {
        return driverType;
    }

    public Supplier<Config> getMemberConfigSupplier() {
        return memberConfigSupplier;
    }

    public int getDriverCount() {
        return driverCount;
    }

    public DriverFactory getDriverFactory() {
        return driverFactory;
    }

    public boolean isUseTerminate() {
        return useTerminate;
    }

    public boolean avoidOverlappingTerminations() {
        return avoidOverlappingTerminations;
    }

    public int getBouncingIntervalSeconds() {
        return bouncingIntervalSeconds;
    }

    public long getMaximumStaleSeconds() {
        return maximumStaleSeconds;
    }

    /**
     * Indicates whether the test will be driven by member or client HazelcastInstances
     */
    public enum DriverType {
        /**
         * Use the single member that is never shutdown during the test as test driver
         */
        ALWAYS_UP_MEMBER,
        /**
         * Setup separate members as test drivers
         */
        MEMBER,
        /**
         * Setup separate lite members as test drivers. Lite members do not affect
         * partition distribution.
         */
        LITE_MEMBER,
        /**
         * Setup clients as test drivers
         */
        CLIENT,
    }
}
